
import socket

def udp_server(host='0.0.0.0', port=12345):
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind((host, port))
    print(f"UDP服务器已启动，监听端口 {port}")
    while True:
        data, addr = sock.recvfrom(4096)
        print(f"收到来自{addr}的数据: {data}")

if __name__ == "__main__":
    udp_server()
